package com.vo;

import com.github.pagehelper.PageInfo;
import lombok.Data;

@Data
public class Result {

    private int code;//接口状态
    private long count;//数据的数量
    private String msg;//消息提示信息
    private Object data;//数据
    //普通查询
    public static Result success(Object data){
        Result result = new Result();
        result.setCode(0);
        result.setData(data);
        return result;
    }
    //增删改
    public static Result success(String msg){
        Result result = new Result();
        result.setCode(0);
        result.setMsg(msg);
        return result;
    }
    public static Result success(PageInfo pageInfo){
        Result result = new Result();
        result.setCode(0);
        result.setCount(pageInfo.getTotal());
        result.setMsg("获取成功");
        result.setData(pageInfo.getList());
        return result;
    }
    public static Result fail(Object data){
        Result result = new Result();
        result.setCode(0);
        result.setData(data);
        return result;
    }
}
